package com.zyz.K_集合.List接口练习;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author: vick
 * @Date: 2025/3/28
 * @Description:
 * @version: 1.0
 */
public class StudentTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Student> studentList = new ArrayList<>();
        while (true) {
            System.out.println("1：继续录入，0：结束录入");
            int num = scanner.nextInt();
            if (num == 1) {
                System.out.println("姓名：");
                String name = scanner.next();
                System.out.println("年龄：");
                int age = scanner.nextInt();
                Student student = new Student(age, name);
                studentList.add(student);
            }else if (num == 0) {
                break;
            }else {
                System.out.println("请输入正确的提示词");
            }
        }

        for (Student student : studentList) {
            System.out.println(student);
        }
    }
}
